package com.wlq.demo.uitls;

import cn.hutool.core.util.StrUtil;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author csb
 * @description: TODO
 * @date 2024/8/16 14:35
 */
public class EmailUtil {

    public static String getEmail(String rowText) {
        String em = "";
        if (StrUtil.isNotBlank(rowText)){
            String emailRegex = "\\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}\\b";
            Pattern pattern = Pattern.compile(emailRegex);
            Matcher matcher = pattern.matcher(rowText);

            while (matcher.find()) {
                String group = matcher.group();
                em = em + group + "\n";
                System.out.println(group);
            }
        }
        return em;
    }

}
